package com.guigu.yh.springcloud.alibaba.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * 订单控制器
 *
 * @author 张颖辉（zyh）
 * @version 1.0.0
 * @date 2023/03/03
 */
@RestController
public class OrderNacosController {
    @Resource
    private RestTemplate restTemplate;

    @Value("${service-url.nacos-user-service}")
    private String userServiceUrl;

    /**
     * 支付信息 demo
     *
     * @param id id
     * @return {@link String }
     * @author 张颖辉（zyh）
     * @date 2023/03/05
     * @version 1.0.0
     */
    @GetMapping("/consumer/payment/nacos/{id}")
    public String paymentInfo(@PathVariable("id") Integer id) {
        return restTemplate.getForObject(userServiceUrl + "/payment/nacos/" + id, String.class);
    }
}
